package com.ruoyi.common.core.domain.entity;

import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.annotation.Excel.ColumnType;
import com.ruoyi.common.annotation.Excel.Type;
import com.ruoyi.common.annotation.Excels;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.xss.Xss;
import org.springframework.data.annotation.Transient;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * 用户对象 sys_user
 *
 * @author ruoyi
 */
public class SysUser extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @Excel(name = "用户序号", type = Type.EXPORT, cellType = ColumnType.NUMERIC, prompt = "用户编号")
    private Long userId;

    /**
     * 部门ID
     */
    @Excel(name = "部门编号", type = Type.IMPORT)
    private Long deptId;

    /**
     * 用户账号
     */
    @Excel(name = "登录名称")
    private String userName;

    /**
     * 用户昵称
     */
    @Excel(name = "用户名称")
    private String nickName;

    /**
     * 用户邮箱
     */
    @Excel(name = "用户邮箱")
    private String email;

    /**
     * 手机号码
     */
    @Excel(name = "手机号码", cellType = ColumnType.TEXT)
    private String phonenumber;

    /**
     * 用户性别
     */
    @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
    private String sex;

    /**
     * 用户头像
     */
    private String avatar;

    /**
     * 密码
     */
    private String password;

    /**
     * 帐号状态（0正常 1停用）
     */
    @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
    private String status;

    /**
     * 删除标志（0代表存在 2代表删除）
     */
    private String delFlag;

    /**
     * 最后登录IP
     */
    @Excel(name = "最后登录IP", type = Type.EXPORT)
    private String loginIp;

    /**
     * 最后登录时间
     */
    @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
    private Date loginDate;

    /**
     * 部门对象
     */
    @Excels({
            @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
            @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
    })
    private SysDept dept;

    /**
     * 角色对象
     */
    private List<SysRole> roles;

    /**
     * 角色组
     */
    private Long[] roleIds;

    /**
     * 岗位组
     */
    private Long[] postIds;

    /**
     * 角色ID
     */
    private Long roleId;

    @Transient
    private String roleName;


    /**
     * 用户组id
     */
    @Excel(name = "用户组id")
    private Long groupId;

    /**
     * 电话
     */
    @Excel(name = "电话")
    private Long tel;

    @Excel(name = "结算价折扣")
    private Double discount;

    /**
     * 号码复制条件
     */
    @Excel(name = "号码复制条件")
    private String noticemsg;

    /**
     * 订单显示分销商户1全部2部分(指定商户)
     */
    @Excel(name = "订单显示分销商户1全部2部分(指定商户)")
    private String orderStoreType;

    /**
     * 订单显示指定分销商户id
     */
    @Excel(name = "订单显示指定分销商户id")
    private String orderStoreArr;

    /**
     * 订单显示号码仓1全部2部分(指定号码仓)
     */
    @Excel(name = "订单显示号码仓1全部2部分(指定号码仓)")
    private String orderSupplierType;

    /**
     * 订单显示指定号码仓id
     */
    @Excel(name = "订单显示指定号码仓id")
    private String orderSupplierArr;

    /**
     * 订单显示状态1全部2部分(指定状态)
     */
    @Excel(name = "订单显示状态1全部2部分(指定状态)")
    private String orderStatusType;

    /**
     * 订单显示指定状态id
     */
    @Excel(name = "订单显示指定状态id")
    private String orderStatusArr;

    /**
     * 号码显示号码仓1全部2部分指定号码仓
     */
    @Excel(name = "号码显示号码仓1全部2部分指定号码仓")
    private String telSupplierType;


    /**
     * 号码显示指定号码仓id
     */
    @Excel(name = "号码显示指定号码仓id")
    private String telSupplierArr;

    /**
     * 号码显示状态1全部2部分(指定状态)
     */
    @Excel(name = "号码显示状态1全部2部分(指定状态)")
    private Integer telStatusType;

    /**
     * 号码显示指定状态id
     */
    @Excel(name = "号码显示指定状态id")
    private String telStatusArr;

    /**
     * 是否在线1否2是
     */
    @Excel(name = "是否在线1否2是")
    private Integer isOnline;

    /**
     * 弹窗提醒条件1需要在线2无需在线
     */
    @Excel(name = "弹窗提醒条件1需要在线2无需在线")
    private Integer remindType;

    /**
     * 是否参与主播竞赛排名1是2否
     */
    @Excel(name = "是否参与主播竞赛排名1是2否")
    private Integer isAnchorCompetition;

    /**
     * 是否参与客服竞赛排名1是2否
     */
    @Excel(name = "是否参与客服竞赛排名1是2否")
    private Integer isServiceCompetition;

    /**
     * 是否展示订单全部搜索条件1是2否
     */
    @Excel(name = "是否展示订单全部搜索条件1是2否")
    private Integer isOrderOptions;

    /**
     * 发展人编码-ZOP下单使用
     */
    @Excel(name = "发展人编码-ZOP下单使用")
    private String zopReferrercode;

    /**
     * 0不接单1接单
     */
    @Excel(name = "0不接单1接单")
    private String isReceiveOrder;


    public SysUser() {

    }

    public SysUser(Long userId) {
        this.userId = userId;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }

    public boolean isAdmin() {
        return isAdmin(this.userId);
    }

    public static boolean isAdmin(Long userId) {
        return userId != null && (1L == userId || 79L == userId);
    }

    public Long getDeptId() {
        return deptId;
    }

    public void setDeptId(Long deptId) {
        this.deptId = deptId;
    }

    @Xss(message = "用户昵称不能包含脚本字符")
    @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
    public String getNickName() {
        return nickName;
    }

    public void setNickName(String nickName) {
        this.nickName = nickName;
    }

    @Xss(message = "用户账号不能包含脚本字符")
    @NotBlank(message = "用户账号不能为空")
    @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    @Email(message = "邮箱格式不正确")
    @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
    public String getPhonenumber() {
        return phonenumber;
    }

    public void setPhonenumber(String phonenumber) {
        this.phonenumber = phonenumber;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public String getAvatar() {
        return avatar;
    }

    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getDelFlag() {
        return delFlag;
    }

    public void setDelFlag(String delFlag) {
        this.delFlag = delFlag;
    }

    public String getLoginIp() {
        return loginIp;
    }

    public void setLoginIp(String loginIp) {
        this.loginIp = loginIp;
    }

    public Date getLoginDate() {
        return loginDate;
    }

    public void setLoginDate(Date loginDate) {
        this.loginDate = loginDate;
    }

    public SysDept getDept() {
        return dept;
    }

    public void setDept(SysDept dept) {
        this.dept = dept;
    }

    public List<SysRole> getRoles() {
        return roles;
    }

    public void setRoles(List<SysRole> roles) {
        this.roles = roles;
    }

    public Long[] getRoleIds() {
        return roleIds;
    }

    public void setRoleIds(Long[] roleIds) {
        this.roleIds = roleIds;
    }

    public Long[] getPostIds() {
        return postIds;
    }

    public void setPostIds(Long[] postIds) {
        this.postIds = postIds;
    }

    public Long getRoleId() {
        return roleId;
    }

    public void setRoleId(Long roleId) {
        this.roleId = roleId;
    }


    public Long getGroupId() {
        return groupId;
    }

    public void setGroupId(Long groupId) {
        this.groupId = groupId;
    }

    public Long getTel() {
        return tel;
    }

    public void setTel(Long tel) {
        this.tel = tel;
    }


    public void setDiscount(Double discount) {
        this.discount = discount;
    }

    public Double getDiscount() {
        return discount;
    }

    public String getNoticemsg() {
        return noticemsg;
    }

    public void setNoticemsg(String noticemsg) {
        this.noticemsg = noticemsg;
    }

    public String getOrderStoreType() {
        return orderStoreType;
    }

    public void setOrderStoreType(String orderStoreType) {
        this.orderStoreType = orderStoreType;
    }

    public String getOrderStoreArr() {
        return orderStoreArr;
    }

    public void setOrderStoreArr(String orderStoreArr) {
        this.orderStoreArr = orderStoreArr;
    }

    public String getOrderSupplierType() {
        return orderSupplierType;
    }

    public void setOrderSupplierType(String orderSupplierType) {
        this.orderSupplierType = orderSupplierType;
    }

    public String getOrderSupplierArr() {
        return orderSupplierArr;
    }

    public void setOrderSupplierArr(String orderSupplierArr) {
        this.orderSupplierArr = orderSupplierArr;
    }

    public String getOrderStatusType() {
        return orderStatusType;
    }

    public void setOrderStatusType(String orderStatusType) {
        this.orderStatusType = orderStatusType;
    }

    public String getOrderStatusArr() {
        return orderStatusArr;
    }

    public void setOrderStatusArr(String orderStatusArr) {
        this.orderStatusArr = orderStatusArr;
    }

    public String getTelSupplierType() {
        return telSupplierType;
    }

    public void setTelSupplierType(String telSupplierType) {
        this.telSupplierType = telSupplierType;
    }

    public String getTelSupplierArr() {
        return telSupplierArr;
    }

    public void setTelSupplierArr(String telSupplierArr) {
        this.telSupplierArr = telSupplierArr;
    }

    public Integer getTelStatusType() {
        return telStatusType;
    }

    public void setTelStatusType(Integer telStatusType) {
        this.telStatusType = telStatusType;
    }

    public String getTelStatusArr() {
        return telStatusArr;
    }

    public void setTelStatusArr(String telStatusArr) {
        this.telStatusArr = telStatusArr;
    }


    public Integer getIsOnline() {
        return isOnline;
    }

    public void setIsOnline(Integer isOnline) {
        this.isOnline = isOnline;
    }

    public Integer getRemindType() {
        return remindType;
    }

    public void setRemindType(Integer remindType) {
        this.remindType = remindType;
    }

    public Integer getIsAnchorCompetition() {
        return isAnchorCompetition;
    }

    public void setIsAnchorCompetition(Integer isAnchorCompetition) {
        this.isAnchorCompetition = isAnchorCompetition;
    }

    public Integer getIsServiceCompetition() {
        return isServiceCompetition;
    }

    public void setIsServiceCompetition(Integer isServiceCompetition) {
        this.isServiceCompetition = isServiceCompetition;
    }

    public Integer getIsOrderOptions() {
        return isOrderOptions;
    }

    public void setIsOrderOptions(Integer isOrderOptions) {
        this.isOrderOptions = isOrderOptions;
    }

    public String getZopReferrercode() {
        return zopReferrercode;
    }

    public void setZopReferrercode(String zopReferrercode) {
        this.zopReferrercode = zopReferrercode;
    }

    public String getIsReceiveOrder() {
        return isReceiveOrder;
    }

    public void setIsReceiveOrder(String isReceiveOrder) {
        this.isReceiveOrder = isReceiveOrder;
    }

    public String getRoleName() {
        return roleName;
    }

    public void setRoleName(String roleName) {
        this.roleName = roleName;
    }

    @Override
    public String toString() {
        return "SysUser{" +
                "userId=" + userId +
                ", deptId=" + deptId +
                ", userName='" + userName + '\'' +
                ", nickName='" + nickName + '\'' +
                ", email='" + email + '\'' +
                ", phonenumber='" + phonenumber + '\'' +
                ", sex='" + sex + '\'' +
                ", avatar='" + avatar + '\'' +
                ", password='" + password + '\'' +
                ", status='" + status + '\'' +
                ", delFlag='" + delFlag + '\'' +
                ", loginIp='" + loginIp + '\'' +
                ", loginDate=" + loginDate +
                ", dept=" + dept +
                ", roles=" + roles +
                ", roleIds=" + Arrays.toString(roleIds) +
                ", postIds=" + Arrays.toString(postIds) +
                ", roleId=" + roleId +
                ", groupId=" + groupId +
                ", tel=" + tel +
                ", discount='" + discount + '\'' +
                ", noticemsg='" + noticemsg + '\'' +
                ", orderStoreType='" + orderStoreType + '\'' +
                ", orderStoreArr='" + orderStoreArr + '\'' +
                ", orderSupplierType='" + orderSupplierType + '\'' +
                ", orderSupplierArr='" + orderSupplierArr + '\'' +
                ", orderStatusType='" + orderStatusType + '\'' +
                ", orderStatusArr='" + orderStatusArr + '\'' +
                ", telSupplierType='" + telSupplierType + '\'' +
                ", telSupplierArr='" + telSupplierArr + '\'' +
                ", telStatusType=" + telStatusType +
                ", telStatusArr='" + telStatusArr + '\'' +
                ", isOnline=" + isOnline +
                ", remindType=" + remindType +
                ", isAnchorCompetition=" + isAnchorCompetition +
                ", isServiceCompetition=" + isServiceCompetition +
                ", isOrderOptions=" + isOrderOptions +
                ", zopReferrercode='" + zopReferrercode + '\'' +
                ", isReceiveOrder='" + isReceiveOrder + '\'' +
                '}';
    }
}
